// This example shows how to read 4 items at once, and display their values, timestamps and qualities. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Diagnostics; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.OperationModel; namespace DocExamples.DataAccess._EasyDAClient { partial class ReadMultipleItems { public static void Main1() { // Instantiate the client object. var client = new EasyDAClient(); DAVtqResult[] vtqResults = client.ReadMultipleItems("OPCLabs.KitServer.2", new DAItemDescriptor[] { "Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4" }); for (int i = 0; i < vtqResults.Length; i++) { Debug.Assert(vtqResults[i] != null); if (vtqResults[i].Succeeded) Console.WriteLine("vtqResults[{0}].Vtq: {1}", i, vtqResults[i].Vtq); else Console.WriteLine("vtqResults[{0}] *** Failure: {1}", i, vtqResults[i].ErrorMessageBrief); } } } }
# This example shows how to read 4 items at once, and display their values, timestamps and qualities. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. #requires -Version 5.1 using namespace OpcLabs.EasyOpc.DataAccess # The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows . Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll" # Instantiate the client object. $client = New-Object EasyDAClient $vtqResults = [IEasyDAClientExtension]::ReadMultipleItems($client, "OPCLabs.KitServer.2", @( (New-Object DAItemDescriptor("Simulation.Random")), (New-Object DAItemDescriptor("Trends.Ramp (1 min)")), (New-Object DAItemDescriptor("Trends.Sine (1 min)")), (New-Object DAItemDescriptor("Simulation.Register_I4")) )) for ($i = 0; $i -lt $vtqResults.Length; $i++) { $vtqResult = $vtqResults[$i] if ($vtqResult.Succeeded) { Write-Host "vtqResults[$($i)].Vtq: $($vtqResult.Vtq)" } else { Write-Host "vtqResults[$($i)] *** Failure: $($vtqResult.ErrorMessageBrief)" } }
' This example shows how to read 4 items at once, and display their values, timestamps and qualities. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.DataAccess Imports OpcLabs.EasyOpc.DataAccess.OperationModel Namespace DataAccess._EasyDAClient Partial Friend Class ReadMultipleItems Public Shared Sub Main1() Dim client = New EasyDAClient() Dim vtqResults() As DAVtqResult = client.ReadMultipleItems( "OPCLabs.KitServer.2", New DAItemDescriptor() {"Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"}) For i = 0 To vtqResults.Length - 1 Debug.Assert(vtqResults(i) IsNot Nothing) If vtqResults(i).Succeeded Then Console.WriteLine("vtqResult[{0}].Vtq: {1}", i, vtqResults(i).Vtq) Else Console.WriteLine("vtqResult[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief) End If Next i End Sub End Class End Namespace
// This example shows how to read 4 items at once, and display their values, timestamps and qualities. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. $ReadItemArguments1 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments"); $ReadItemArguments1->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2"; $ReadItemArguments1->ItemDescriptor->ItemID = "Simulation.Random"; $ReadItemArguments2 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments"); $ReadItemArguments2->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2"; $ReadItemArguments2->ItemDescriptor->ItemID = "Trends.Ramp (1 min)"; $ReadItemArguments3 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments"); $ReadItemArguments3->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2"; $ReadItemArguments3->ItemDescriptor->ItemID = "Trends.Sine (1 min)"; $ReadItemArguments4 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments"); $ReadItemArguments4->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2"; $ReadItemArguments4->ItemDescriptor->ItemID = "Simulation.Register_I4"; $arguments[0] = $ReadItemArguments1; $arguments[1] = $ReadItemArguments2; $arguments[2] = $ReadItemArguments3; $arguments[3] = $ReadItemArguments4; $Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient"); $results = $Client->ReadMultipleItems($arguments); for ($i = 0; $i < count($results); $i++) { $VtqResult = $results[$i]; if ($VtqResult->Succeeded) printf("results[d].Vtq.ToString()s\n", $i, $VtqResult->Vtq->ToString); else printf("results[d]: *** Failures\n", $i, $VtqResult->ErrorMessageBrief); }
// This example shows how to read 4 items at once, and display their values, timestamps and qualities. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure ReadMultipleItems.Main; var Arguments: OleVariant; Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient; I: Cardinal; ReadItemArguments1: _DAReadItemArguments; ReadItemArguments2: _DAReadItemArguments; ReadItemArguments3: _DAReadItemArguments; ReadItemArguments4: _DAReadItemArguments; VtqResult: _DAVtqResult; Results: OleVariant; begin ReadItemArguments1 := CoDAReadItemArguments.Create; ReadItemArguments1.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2'; ReadItemArguments1.ItemDescriptor.ItemID := 'Simulation.Random'; ReadItemArguments2 := CoDAReadItemArguments.Create; ReadItemArguments2.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2'; ReadItemArguments2.ItemDescriptor.ItemID := 'Trends.Ramp (1 min)'; ReadItemArguments3 := CoDAReadItemArguments.Create; ReadItemArguments3.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2'; ReadItemArguments3.ItemDescriptor.ItemID := 'Trends.Sine (1 min)'; ReadItemArguments4 := CoDAReadItemArguments.Create; ReadItemArguments4.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2'; ReadItemArguments4.ItemDescriptor.ItemID := 'Simulation.Register_I4'; Arguments := VarArrayCreate([0, 3], varVariant); Arguments[0] := ReadItemArguments1; Arguments[1] := ReadItemArguments2; Arguments[2] := ReadItemArguments3; Arguments[3] := ReadItemArguments4; // Instantiate the client object Client := CoEasyDAClient.Create; TVarData(Results).VType := varArray or varVariant; TVarData(Results).VArray := PVarArray( Client.ReadMultipleItems(Arguments)); // Display results for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do begin VtqResult := IInterface(Results[I]) as _DAVtqResult; if VtqResult.Succeeded then WriteLn('results(', i, ').Vtq.ToString(): ', VtqResult.Vtq.ToString) else WriteLn('results(', i, ') *** Failure: ', VtqResult.ErrorMessageBrief); end; VarClear(Results); VarClear(Arguments); end;
// This example shows how to read 4 items at once, and display their values, timestamps and qualities. mle_outputtext.Text = "" // Instantiate the client object OLEObject client client = CREATE OLEObject client.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") // Prepare arguments. OLEObject readItemArguments1 readItemArguments1 = CREATE OLEObject readItemArguments1.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") readItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" readItemArguments1.ItemDescriptor.ItemID = "Simulation.Random" OLEObject readItemArguments2 readItemArguments2 = CREATE OLEObject readItemArguments2.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") readItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" readItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)" OLEObject readItemArguments3 readItemArguments3 = CREATE OLEObject readItemArguments3.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") readItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" readItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)" OLEObject readItemArguments4 readItemArguments4 = CREATE OLEObject readItemArguments4.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") readItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" readItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4" OLEObject readItemArgumentsList readItemArgumentsList = CREATE OLEObject readItemArgumentsList.ConnectToNewObject("OpcLabs.BaseLib.Collections.ElasticVector") readItemArgumentsList.Add(readItemArguments1) readItemArgumentsList.Add(readItemArguments2) readItemArgumentsList.Add(readItemArguments3) readItemArgumentsList.Add(readItemArguments4) // Obtain values/timestamps/qualities. OLEObject vtqResultList vtqResultList = client.ReadItemList(readItemArgumentsList) // Display results Int i FOR i = 0 TO vtqResultList.Count - 1 OLEObject vtqResult vtqResult = vtqResultList.Item[i] IF vtqResult.Succeeded THEN mle_outputtext.Text = mle_outputtext.Text + "vtqResult[" + String(i) + "].Vtq: " + String(vtqResult.Vtq) + "~r~n" ELSE mle_outputtext.Text = mle_outputtext.Text + "vtqResult[" + String(i) + "] *** Failure: " + vtqResult.ErrorMessageBrief + "~r~n" END IF NEXT
Rem $Header: $ Rem This example shows how to read 4 items at once, and display their values, timestamps and qualities. Dim ReadItemArguments1 As New OLEObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random" Dim ReadItemArguments2 As New OLEObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)" Dim ReadItemArguments3 As New OLEObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)" Dim ReadItemArguments4 As New OLEObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4" Dim argumentsList As New OLEObject("OpcLabs.BaseLib.Collections.ElasticVector") argumentsList.Add(ReadItemArguments1) argumentsList.Add(ReadItemArguments2) argumentsList.Add(ReadItemArguments3) argumentsList.Add(ReadItemArguments4) 'Dim arguments(3) As OLEObject 'arguments(0) = ReadItemArguments1 'arguments(1) = ReadItemArguments2 'arguments(2) = ReadItemArguments3 'arguments(3) = ReadItemArguments4 Dim Client As New OLEObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") Dim resultList As OLEObject resultList = Client.ReadItemList(argumentsList) Dim n As Integer n = resultList.Count 'Dim results() As Variant 'results = Client.ReadMultipleItems(arguments) Dim i As Integer For i = 0 To n - 1 'For i = results.FirstRowIndex To results.LastRowIndex Dim VtqResult As OLEObject VtqResult = resultList.GetAt(i) 'VtqResult = results(i) If VtqResult.Succeeded Then Dim Vtq As OLEObject Vtq = VtqResult.Vtq Print "results(" + CStr(i) + ").Vtq.ToString(): " + Vtq.ToString() Else Print "results(" + CStr(i) + ") *** Failure: " + VtqResult.ErrorMessageBrief End If Next
REM This example shows how to read 4 items at once, and display their values, timestamps and qualities. REM REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB . REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own REM a commercial license in order to use Online Forums, and we reply to every post. Private Sub ReadMultipleItems_Main_Command_Click() OutputText = "" Dim readArguments1 As New DAReadItemArguments readArguments1.serverDescriptor.ServerClass = "OPCLabs.KitServer.2" readArguments1.ItemDescriptor.itemId = "Simulation.Random" Dim readArguments2 As New DAReadItemArguments readArguments2.serverDescriptor.ServerClass = "OPCLabs.KitServer.2" readArguments2.ItemDescriptor.itemId = "Trends.Ramp (1 min)" Dim readArguments3 As New DAReadItemArguments readArguments3.serverDescriptor.ServerClass = "OPCLabs.KitServer.2" readArguments3.ItemDescriptor.itemId = "Trends.Sine (1 min)" Dim readArguments4 As New DAReadItemArguments readArguments4.serverDescriptor.ServerClass = "OPCLabs.KitServer.2" readArguments4.ItemDescriptor.itemId = "Simulation.Register_I4" Dim arguments(3) As Variant Set arguments(0) = readArguments1 Set arguments(1) = readArguments2 Set arguments(2) = readArguments3 Set arguments(3) = readArguments4 ' Instantiate the client object Dim client As New EasyDAClient Dim results() As Variant results = client.ReadMultipleItems(arguments) ' Display results Dim i: For i = LBound(results) To UBound(results) Dim vtqResult As DAVtqResult: Set vtqResult = results(i) If vtqResult.Succeeded Then OutputText = OutputText & "results(" & i & ").Vtq: " & vtqResult.vtq & vbCrLf Else OutputText = OutputText & "results(" & i & ") *** Failure: " & vtqResult.ErrorMessageBrief & vbCrLf End If Next End Sub
Rem This example shows how to read 4 items at once, and display their values, timestamps and qualities. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random" Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)" Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)" Dim ReadItemArguments4: Set ReadItemArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4" Dim arguments(3) Set arguments(0) = ReadItemArguments1 Set arguments(1) = ReadItemArguments2 Set arguments(2) = ReadItemArguments3 Set arguments(3) = ReadItemArguments4 Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") Dim results: results = Client.ReadMultipleItems(arguments) Dim i: For i = LBound(results) To UBound(results) Dim VtqResult: Set VtqResult = results(i) If VtqResult.Succeeded Then WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString() Else WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief End If Next
# This example shows how to read 4 items at once, and display their values, timestamps and qualities. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.DataAccess import * from OpcLabs.EasyOpc.DataAccess.OperationModel import * from OpcLabs.EasyOpc.OperationModel import * # Instantiate the client object. client = EasyDAClient() # vtqResultArray = client.ReadMultipleItems([ DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Random')), DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Ramp (1 min)')), DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Sine (1 min)')), DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_I4')), ]) for i, vtqResult in enumerate(vtqResultArray): assert vtqResult is not None if vtqResult.Succeeded: print('vtqResultArray[', i, '].Vtq: ', vtqResult.Vtq, sep='') else: print('vtqResultArray[', i, '] *** Failure: ', vtqResult.ErrorMessageBrief, sep='')
// This example repeatedly reads a large number of items. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.OperationModel; namespace DocExamples.DataAccess._EasyDAClient { partial class ReadMultipleItems { private const int RepeatCount = 10; private const int NumberOfItems = 1000; public static void ManyRepeat() { Console.WriteLine("Creating array of arguments..."); var arguments = new DAReadItemArguments[NumberOfItems]; for (int i = 0; i < NumberOfItems; i++) { int copy = (i / 100) + 1; int phase = i % 100; string itemId = FormattableString.Invariant($"Simulation.Incrementing.Copy_{copy}.Phase_{phase}"); Console.WriteLine(itemId); var readItemArguments = new DAReadItemArguments("OPCLabs.KitServer.2", itemId); arguments[i] = readItemArguments; } // Instantiate the client object. var client = new EasyDAClient(); for (int iRepeat = 1; iRepeat <= RepeatCount; iRepeat++) { Console.WriteLine("Reading items..."); DAVtqResult[] vtqResults = client.ReadMultipleItems(arguments); int successCount = 0; foreach (DAVtqResult vtqResult in vtqResults) if (vtqResult.Succeeded) successCount++; Console.WriteLine($"Success count: {successCount}"); } } } }
Rem This example repeatedly reads a large number of items. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Const repeatCount = 10 Const numberOfItems = 1000 WScript.Echo "Creating array of arguments..." Dim arguments(): ReDim arguments(numberOfItems - 1) Dim i: For i = 0 To numberOfItems - 1 Dim copy: copy = Int(i / 100) + 1 Dim phase: phase = i Mod 100 Dim itemId: itemId = "Simulation.Incrementing.Copy_" & copy & ".Phase_" & phase WScript.Echo itemId Dim ReadItemArguments: Set ReadItemArguments = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments.ItemDescriptor.ItemID = itemId Set arguments(i) = ReadItemArguments Next Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") Dim iRepeat: For iRepeat = 1 To repeatCount WScript.Echo "Reading items..." Dim results: results = Client.ReadMultipleItems(arguments) Dim successCount: successCount = 0 For i = LBound(results) To UBound(results) Dim VtqResult: Set VtqResult = results(i) If VtqResult.Succeeded Then successCount = successCount + 1 Next WScript.Echo "Success count: " & successCount Next
# This example repeatedly reads a large number of items. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.DataAccess import * from OpcLabs.EasyOpc.DataAccess.OperationModel import * from OpcLabs.EasyOpc.OperationModel import * REPEAT_COUNT = 10 NUMBER_OF_ITEMS = 1000 print('Creating array of arguments...') argumentArray = [None]*NUMBER_OF_ITEMS for i in range(NUMBER_OF_ITEMS): copy = (i//100) + 1 phase = i % 100 itemId = 'Simulation.Incrementing.Copy_{}.Phase_{}'.format(copy, phase) print(itemId) # readItemArguments = DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor(itemId)) argumentArray[i] = readItemArguments # Instantiate the client object. client = EasyDAClient() # for iRepeat in range(1, REPEAT_COUNT + 1): print('Reading items...') vtqResultArray = client.ReadMultipleItems(argumentArray) # successCount = 0 for vtqResult in vtqResultArray: if vtqResult.Succeeded: successCount = successCount + 1 print('Success count: ', successCount, sep='') print('Finished.')
// This example shows how to read 4 items at once synchronously, and display their values, timestamps and qualities. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Diagnostics; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.OperationModel; namespace DocExamples.DataAccess._EasyDAClient { partial class ReadMultipleItems { public static void Synchronous() { // Instantiate the client object. var client = new EasyDAClient(); // Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are // allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves // only the synchronous method available for selection. client.InstanceParameters.Mode.AllowAsynchronousMethod = false; DAVtqResult[] vtqResults = client.ReadMultipleItems("OPCLabs.KitServer.2", new DAItemDescriptor[] { "Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4" }); for (int i = 0; i < vtqResults.Length; i++) { Debug.Assert(vtqResults[i] != null); if (vtqResults[i].Succeeded) Console.WriteLine("vtqResult[{0}].Vtq: {1}", i, vtqResults[i].Vtq); else Console.WriteLine("vtqResult[{0}] *** Failure: {1}", i, vtqResults[i].ErrorMessageBrief); } } // Example output: // //vtqResult[0].Vtq: 0.00125125888851588 { System.Double} @2020-04-10T15:29:20.642; GoodNonspecific(192) //vtqResult[1].Vtq: 0.344052940607071 {System.Double} @2020-04-10T15:29:20.643; GoodNonspecific(192) //vtqResult[2].Vtq: 0.830410616568378 {System.Double} @2020-04-10T15:29:20.643; GoodNonspecific(192) //vtqResult[3].Vtq: 0 {System.Int32} @1601-01-01T00:00:00.000; GoodNonspecific(192) } }
' This example shows how to read 4 items at once synchronously, and display their values, timestamps and qualities. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.DataAccess Imports OpcLabs.EasyOpc.DataAccess.OperationModel Namespace DataAccess._EasyDAClient Partial Friend Class ReadMultipleItems Public Shared Sub Synchronous() ' Instantiate the client object. Dim client = New EasyDAClient() ' Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are ' allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves ' only the synchronous method available for selection. client.InstanceParameters.Mode.AllowAsynchronousMethod = False Dim vtqResults() As DAVtqResult = client.ReadMultipleItems("OPCLabs.KitServer.2", New DAItemDescriptor() {"Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"}) For i = 0 To vtqResults.Length - 1 Debug.Assert(vtqResults(i) IsNot Nothing) If vtqResults(i).Succeeded Then Console.WriteLine("vtqResult[{0}].Vtq: {1}", i, vtqResults(i).Vtq) Else Console.WriteLine("vtqResult[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief) End If Next i End Sub ' Example output: ' 'vtqResult[0].Vtq: 0.00125125888851588 { System.Double} @2020-04-10T15:29:20.642; GoodNonspecific(192) 'vtqResult[1].Vtq: 0.344052940607071 {System.Double} @2020-04-10T15:29:20.643; GoodNonspecific(192) 'vtqResult[2].Vtq: 0.830410616568378 {System.Double} @2020-04-10T15:29:20.643; GoodNonspecific(192) 'vtqResult[3].Vtq: 0 {System.Int32} @1601-01-01T00:00:00.000; GoodNonspecific(192) End Class End Namespace
Rem This example shows how to read 4 items at once synchronously, and display their values, timestamps and qualities. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random" Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)" Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)" Dim ReadItemArguments4: Set ReadItemArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4" Dim arguments(3) Set arguments(0) = ReadItemArguments1 Set arguments(1) = ReadItemArguments2 Set arguments(2) = ReadItemArguments3 Set arguments(3) = ReadItemArguments4 Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") ' Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are allowed, and ' the component picks a suitable method automatically. Disallowing asynchronous method leaves only the synchronous method ' available for selection. Client.InstanceParameters.Mode.AllowAsynchronousMethod = False Dim results: results = Client.ReadMultipleItems(arguments) Dim i: For i = LBound(results) To UBound(results) Dim VtqResult: Set VtqResult = results(i) If VtqResult.Succeeded Then WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString() Else WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief End If Next
# This example shows how to read 4 items at once synchronously, and display their values, timestamps and qualities. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.DataAccess import * from OpcLabs.EasyOpc.DataAccess.OperationModel import * from OpcLabs.EasyOpc.OperationModel import * # Instantiate the client object. client = EasyDAClient() # Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are # allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves # only the synchronous method available for selection. client.InstanceParameters.Mode.AllowAsynchronousMethod = False # vtqResultArray = client.ReadMultipleItems([ DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Random')), DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Ramp (1 min)')), DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Sine (1 min)')), DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_I4')), ]) for i, vtqResult in enumerate(vtqResultArray): assert vtqResult is not None if vtqResult.Succeeded: print('vtqResultArray[', i, '].Vtq: ', vtqResult.Vtq, sep='') else: print('vtqResultArray[', i, '] *** Failure: ', vtqResult.ErrorMessageBrief, sep='')
Rem This example shows how to read 2 items (first valid, second invalid), test for success of each read and display either Rem the DAVtq or the Exception. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random" Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments2.ItemDescriptor.ItemID = "UnknownItem" Dim arguments(1) Set arguments(0) = ReadItemArguments1 Set arguments(1) = ReadItemArguments2 Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") Dim results: results = Client.ReadMultipleItems(arguments) Dim i: For i = LBound(results) To UBound(results) Dim VtqResult: Set VtqResult = results(i) If VtqResult.Succeeded Then WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString() Else WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief End If Next
# This example shows how to read 2 items (first valid, second invalid), test for success of each read and display either # the DAVtq or the Exception. # # The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32". # CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available! # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . import win32com.client # Instantiate the client object client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') # readItemArguments1 = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments') readItemArguments1.ServerDescriptor.ServerClass = 'OPCLabs.KitServer.2' readItemArguments1.ItemDescriptor.ItemID = 'Simulation.Random' readItemArguments2 = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments') readItemArguments2.ServerDescriptor.ServerClass = 'OPCLabs.KitServer.2' readItemArguments2.ItemDescriptor.ItemID = 'UnknownItem' arguments = [ readItemArguments1, readItemArguments2, ] results = client.ReadMultipleItems(arguments) for i, vtqResult in enumerate(results): if vtqResult.Succeeded: print('results(' + str(i) + '): ' + str(vtqResult.Vtq)) else: print('results(' + str(i) + ') *** Failure: ' + vtqResult.ErrorMessageBrief)
Rem This example attempts to read 3 items (first valid, second invalid, third valid again), and display their values, Rem timestamps and qualities. Without testing for a success, a run-time error occurs when accessing the Vtq property Rem of a failed result. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random" Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments2.ItemDescriptor.ItemID = "UnknownItem" Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2" ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Ramp (1 min)" Dim arguments(2) Set arguments(0) = ReadItemArguments1 Set arguments(1) = ReadItemArguments2 Set arguments(2) = ReadItemArguments3 Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") Dim results: results = Client.ReadMultipleItems(arguments) Dim i: For i = LBound(results) To UBound(results) ' This is an anti-example - you should not access the Vtq property without testing the success first! WScript.Echo "results(" & i & ").Vtq.ToString(): " & results(i).Vtq.ToString() Next
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
Documentation Home, Send Documentation Feedback. Technical Support